//
//  TitleCollectionViewCell.m
//  礼物说
//
//  Created by dllo on 16/4/21.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "TitleCollectionViewCell.h"

#define kFONT(m) [UIFont systemFontOfSize:m]

@interface TitleCollectionViewCell ()

@end

@implementation TitleCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createTitleCell];
    }
    return self;
}

// 重写属性model的set方法
- (void)setModel:(TitleModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.titleLable.text = model.name;
}

- (void)dealloc {
    [_model release];
    [_titleLable release];
    [super dealloc];
}

- (void)createTitleCell {
    self.titleLable = [[BaseLabel alloc] init];
    [self.contentView addSubview:_titleLable];
    [_titleLable release];
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super layoutSubviews];
    _titleLable.frame = self.contentView.frame;
    _titleLable.font = kFONT(20);
    if (kWIDTHCELL < 375) {
        _titleLable.font = kFONT(15);
    }
    _titleLable.textAlignment = NSTextAlignmentCenter;
}

@end
